package com.compass.mobile.ui.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.compass.mobile.databinding.ItemImageCaseBinding
import com.compass.mobile.framework.adapter.BaseBindViewHolder
import com.compass.mobile.framework.adapter.BaseMultiItemAdapter
import saveAs
import setUrlRound

/**
 * Description： 患者图片
 * Date:2024/11/22 21:47
 */
class PictureAdapter constructor(private var itemType: Int) :
    BaseMultiItemAdapter<String>() {


    //用来实现多item布局
    override fun getDefItemViewType(position: Int): Int {
        return itemType
    }


    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<ViewBinding>,
        item: String?,
        position: Int
    ) {
        if (item == null) return
        //1、问诊单， 2、问诊单详情
        when (holder.itemViewType) {
            1 -> {
                val binding = holder.binding.saveAs<ItemImageCaseBinding>()
                binding.apply {

                    imgCase.setUrlRound(item, 5)

                }
            }

            else -> {
                val binding = holder.binding.saveAs<ItemImageCaseBinding>()
                binding.apply {
                    imgCase.setUrlRound(item, 5)
                }

            }
        }
    }

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): ViewBinding {
        return when (viewType) {
            1 -> {
                ItemImageCaseBinding.inflate(layoutInflater, parent, false)
            }

            else -> {
                ItemImageCaseBinding.inflate(layoutInflater, parent, false)
            }
        }

    }
}